home *** CD-ROM | disk | FTP | other *** search
- Path: composer.inav.net!news
- From: Aaron Plattner <aaronp@biovax.biology.uiowa.edu>
- Newsgroups: comp.lang.c++
- Subject: Re: Char to int??
- Date: Sat, 20 Apr 1996 12:29:15 -0500
- Organization: Internet Navigator, Inc.
- Message-ID: <31791EEB.5E5F@biovax.biology.uiowa.edu>
- References: <4ai0ov$l88@nosy.bart.nl> <DpzMrD.F8@pgh.nauticom.net>
- NNTP-Posting-Host: dip18.inav.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01Gold (Win95; I)
-
- >Steven van den Berg (painless@bart.nl) wrote:
- >: Can somebody please tell me how you can covert a char to an int. I
- >: want to convert a char like "a" to the scancode of a and put that into
- >: an int.
- >
- >Anotherway that can work, depending on what you need...try using
- >
- >{
- > char c[]="car";
- > int Crap;
- >
- > Crap=atoi(c);
- >}
- >
- >Don't ask me what library you need.
- >-Jamshid
-
- I don't quite agree with you. You would use atoi to do something like this:
-
- {
- char c[]="42";
- int x;
- x=atoi(c);
- /* x now equals 42 */
- }
-
- What you can do is try a type-cast. For example:
-
- {
- char c='a';
- int x;
- x=(int)c;
- /* x now equals the ascii value of "a" */
- }
-
- --Aaron Plattner
-
- P.S. atoi() is in the stdlib.h include file
-